<!DOCTYPE html>
<html>
<html xmlns:th="http://www.thymeleaf.org">
		<meta charset="utf-8" />
		<title>个人信息</title>
		<link rel="stylesheet" type="text/css" href="../../css/public.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/mygrxx.css" />
	</head>
	<body>
	<div th:replace="~{front/public/topmargin::topbar}"></div>

	<!------------------------------idea------------------------------>
	<div class="address mt">
		<div class="wrapper clearfix">
			<a href="index" class="fl">首页</a>
			<span>/</span>
			<a href="mygxin" class="on">个人信息</a>
		</div>
	</div>
		<!------------------------------Bott------------------------------>
		<div class="Bott">
			<div class="wrapper clearfix">
<!--				<div class="zuo fl">-->
<!--					<h3>-->
<!--						<a href="#"><img img id="img-avatar" src="../../img/tx.png" width="90px" height="90px"/></a>-->
<!--						<p class="clearfix"><span class="fl">[羊羊羊]</span><span class="fr">[退出登录]</span></p>-->
<!--					</h3>-->
<!--					<div>-->
<!--						<h4>我的交易</h4>-->
<!--						<ul>-->
<!--							<li><a href="cart">我的购物车</a></li>-->
<!--							<li><a href="myorderq">我的订单</a></li>-->
<!--							<li><a href="myprod">评价晒单</a></li>-->
<!--						</ul>-->
<!--						<h4>个人中心</h4>-->
<!--						<ul>-->
<!--							<li><a href="mygxin">我的中心</a></li>-->
<!--							<li><a href="address">地址管理</a></li>-->
<!--						</ul>-->
<!--						<h4>账户管理</h4>-->
<!--						<ul>-->
<!--							<li><a href="mygrxx">个人信息</a></li>-->
<!--							<li  class="on"><a href="remima">修改密码</a></li>-->
<!--						</ul>-->
<!--					</div>-->
<!--				</div>-->
				<div th:replace="~{front/public/sidebar::leftbar}"></div>
				<div class="you fl">
					<h2>修改密码</h2>
					<form action="#" id="form-change-password" method="post" class="remima">
<!--						<p><span>选择验证身份方式：</span><input type="checkbox" />密码验证  <input type="checkbox" />邮箱验证 </p>-->
						<p><span>原密码：</span><input style="border:1px solid #dbdbdb; font-size: 20px;padding-left:10px; " type="password"  id="oldPassword" name="oldPassword"  /></p>
						<p class="op">输入原密码</p>
						<p><span>
							新密码：</span><input style="border:1px solid #dbdbdb; font-size: 20px;padding-left:10px; " type="password" id="newPassword" name="newPassword"  /></p>
						<p class="op">6-16 个字符，需使用字母、数字组合，不能使用纯数字、纯字母</p>
						<p><span>重复新密码：</span><input style="border:1px solid #dbdbdb; font-size: 20px;padding-left:10px; " type="password"    id="newPasswordAgain" name="newPasswordAgain" /></p>
						<p class="op">请再次输入密码</p>
						<p><span>验证码：</span><input style="border:1px solid #dbdbdb; font-size: 20px;padding-left:10px; " type="password"/><img src="../../img/temp/code.jpg" alt="" /></p>
						<p class="op">按右图输入验证码，不区分大小写</p>
						<input type="button" align="center" id="changePassword" value="提交" />
					</form>
				</div>
			</div>
		</div>
		
		<!--返回顶部-->
		<div class="gotop">
			<a href="cart">
			<dl>
				<dt><img src="../../img/gt1.png"/></dt>
				<dd>去购<br />物车</dd>
			</dl>
			</a>
			<a href="#" class="dh">
			<dl>
				<dt><img src="../../img/gt2.png"/></dt>
				<dd>联系<br />客服</dd>
			</dl>
			</a>
			<a href="mygxin">
			<dl>
				<dt><img src="../../img/gt3.png"/></dt>
				<dd>个人<br />中心</dd>
			</dl>
			</a>
			<a href="#" class="toptop" style="display: none">
			<dl>
				<dt><img src="../../img/gt4.png"/></dt>
				<dd>返回<br />顶部</dd>
			</dl>
			</a>
			<p>400-800-8200</p>
		</div>
		<!--footer-->
		<div class="footer">
			<div class="top">
				<div class="wrapper">
					<div class="clearfix">
						<a href="#2" class="fl"><img src="../../img/foot1.png"/></a>
						<span class="fl">7天无理由退货</span>
					</div>
					<div class="clearfix">
						<a href="#2" class="fl"><img src="../../img/foot2.png"/></a>
						<span class="fl">15天免费换货</span>
					</div>
					<div class="clearfix">
						<a href="#2" class="fl"><img src="../../img/foot3.png"/></a>
						<span class="fl">满599包邮</span>
					</div>
					<div class="clearfix">
						<a href="#2" class="fl"><img src="../../img/foot4.png"/></a>
						<span class="fl">手机特色服务</span>
					</div>
				</div>
			</div>
			<p class="dibu">最家家居&copy;2013-2017公司版权所有 京ICP备080100-44备0000111000号<br />
			违法和不良信息举报电话：400-800-8200，本网站所列数据，除特殊说明，所有数据均出自我司实验室测试</p>
		</div>
		<script src="../../js/jquery-3.5.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/public.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/user.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" src="../../js/sweetalert.min.js"></script>
		<script src="../../js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
	    <script type="text/javascript">
			$(function () {
				//失去焦点时自动匹配正确规范的课程编号
				$('#newPassword').blur(function () {
					var newPassword = $('#newPassword').val();
					var newPasswordPatt = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/;
					if (!newPasswordPatt.test(newPassword)) {
						// alert("格式错误，请按照要求输入复合要求的密码！")
						swal({
							title: '密码格式错误',
							icon: 'warning',
							text: "请确认输入密码符合规范。",
							button: {
								text: "确认",
								value: true,
							}
						}).then(function (isok) {
							if (isok) {
								return false;
							}
						})
					} else {
						// alert("密码符合要求")
						swal({
							title: '密码符合要求',
							icon: 'success',
						}).then(function () {
						})
					}
				})
			})



			function checkpassword() {
				var password = document.getElementById("newPassword").value;
				var repassword = document.getElementById("newPasswordAgain").value;

				if(password == repassword) {
					// document.getElementById("tishi").innerHTML="<br><font color='green'>两次密码输入一致</font>";
					document.getElementById("changePassword").disabled = false;

				}else {
					swal({
						title: '两次输入密码不一致!',
						icon: 'warning',
						button: {
							text: "确认",
							value: true,
						}
					}).then(function (isok) {
						if (isok) {
							location.href = 'remima'
						}
					})
					// document.getElementById("tishi").innerHTML="<br><font color='red'>两次输入密码不一致!</font>";
					document.getElementById("changePassword").disabled = true;
				}
			}








			$(document).ready(function () {
				console.log("from code itself1")
				console.log("cookie中的avatar=" + $.cookie("photo"));
				$("#img-avatar").attr("src", $.cookie("photo"));
			});

				$("#changePassword").click(function() {
					var newPassword = $('#newPassword').val();
					var newPasswordPatt = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/;
					var password = document.getElementById("newPassword").value;
					var repassword = document.getElementById("newPasswordAgain").value;
					if($.trim(newPassword)==null || $.trim(newPassword)==''){
						swal({
							title : "修改操作提示",
							type : "error",
							text : "请检查新密码是否填写完整",
							confirmButtonText : "确定",
							closeOnConfirm : false
						});
						return false;
					}
					if (!newPasswordPatt.test(newPassword)){
						swal({
							title : "修改操作提示",
							type : "error",
							text : "请检查密码是否符合标准！",
							confirmButtonText : "确定",
							closeOnConfirm : false
						});
						return false;
					}

					if (password !== repassword ){
						swal({
							title : "修改操作提示",
							type : "error",
							text : "请检查两次密码输入是否一致！",
							confirmButtonText : "确定",
							closeOnConfirm : false
						});
						return false;
					}

					$.ajax({
						url: "/changePassWord",
						type: "POST",
						data: $("#form-change-password").serialize(),
						dataType: "json",
						success: function(json) {
							if ( json.state == 200) {
								// alert("修改成功！");
								swal({
									title: '修改成功',
									icon: 'success'
								}).then(function () {
									location.href = 'login'
								})
							}else {
								swal({
									title: '修改失败',
									icon: 'warning',
									text: json.message,
									button: {
										text: "确认",
										value: true,
									}
								}).then(function (isok) {
									if (isok) {
										return false;
										location.href = 'remima'
									}
								})
							}
						}
					});
				});
	</script>
	</body>
</html>
